﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NantGoogleCode
{
	public static class NantGoogleCodeUtility
	{
		public static TResult IfNotNull<T, TResult>(this T element, Func<T, TResult> func)
		{
			return element != null ? func(element) : default(TResult);
		}

		public static TResult IfNotNull<T, TResult>(this T element, Func<T, TResult> func, TResult defaultReturnValue)
		{
			return element != null ? func(element) : defaultReturnValue;
		}

		public static TResult IfNotNullOrEmpty<TResult>(this string element, Func<string, TResult> func)
		{
			return !String.IsNullOrEmpty(element) ? func(element) : default(TResult);
		}		
	}
}
